<?php
// ========================== 文件说明 ==========================//
// 本文件说明：系统设置
// ==============================================================//

if(!defined('IN_ROOT') || !isset($php_self) || !preg_match("/[\/\\\\]index\.php$/", $php_self)) {
	exit('Access Denied');
}

//权限检查
//permission();

$settingsmenu = array(
	'basic' => '基本设置',
	'display' => '显示设置',
	'comment' => '评论设置',
	'search' => '搜索设置',
	'dateline' => '时间设置',
	'func' => '功能设置',
	'user' => '用户设置',
	'wap' => 'WAP设置',
	'ban' => '限制设置',
	'js' => 'JS调用设置',
	'rss' => 'RSS订阅设置',
	'sitemap' => 'SiteMap设置',
);

// 更新配置以及配置文件
if($_POST['action'] == 'updatesetting') {
	//$db->query("TRUNCATE TABLE {$tablepre}settings");
	foreach($_POST['setting'] AS $key => $val) {
		$db->query("REPLACE INTO {$tablepre}xna_settings VALUES ('".addslashes($key)."', '".addslashes($val)."')");
	}
	settings_recache();
	redirect('更新系统配置成功', 'index.php?job=config&type='.$type);
} //end update

$query = $db->query("SELECT * FROM {$tablepre}xna_settings");
while($setting = $db->row($query)) {
	$settings[$setting['title']] = htmlspecialchars($setting['value']);
}

ifselected($settings['show_calendar'],'show_calendar');
ifselected($settings['show_categories'],'show_categories');
ifselected($settings['show_archives'],'show_archives');
ifselected($settings['show_statistics'],'show_statistics');
ifselected($settings['show_debug'],'show_debug');
ifselected($settings['random_links'],'random_links');
ifselected($settings['audit_comment'],'audit_comment');
ifselected($settings['seccode'],'seccode');
ifselected($settings['comment_order'],'comment_order');
ifselected($settings['allow_search_comments'],'allow_search_comments');
ifselected($settings['attachments_thumbs'],'attachments_thumbs');
ifselected($settings['display_attach'],'display_attach');
ifselected($settings['remote_open'],'remote_open');
ifselected($settings['close'],'close');
ifselected($settings['closereg'],'closereg');
ifselected($settings['seccode_enable'],'seccode_enable');
ifselected($settings['usercheck'],'usercheck');
ifselected($settings['gzipcompress'],'gzipcompress');
ifselected($settings['showmsg'],'showmsg');
ifselected($settings['audit_trackback'],'audit_trackback');
ifselected($settings['trackback_order'],'trackback_order');
ifselected($settings['smarturl'],'smarturl');
ifselected($settings['watermark'],'watermark');
ifselected($settings['wap_enable'],'wap_enable');
ifselected($settings['banip_enable'],'banip_enable');
ifselected($settings['spam_enable'],'spam_enable');
ifselected($settings['js_enable'],'js_enable');
ifselected($settings['rss_enable'],'rss_enable');
ifselected($settings['rss_all_output'],'rss_all_output');
ifselected($settings['sitemap_enable'],'sitemap_enable');

$viewmode = '';
$viewmode[$settings['viewmode']] = 'selected';
$article_order = '';
$article_order[$settings['article_order']] = 'selected';
$collect = '';
$collect[$settings['collect']] = 'selected';
$related_order[$settings['related_order']] = 'selected';
$attack_reject[$settings['attack_reject']] = 'selected';
$settings['server_timezone'] < 0 ? ${'zone_0'.str_replace('.','_',abs($settings['server_timezone']))}='selected' : ${'zone_'.str_replace('.','_',$settings['server_timezone'])}='selected';
$waterpos[$settings['waterpos']] = 'selected';

$subnav = '';
if (in_array($type,array_flip($settingsmenu))) {
	$subnav = $settingsmenu[$type];
}
$navlink_L = ' &raquo; <a href="index.php?job=config">系统设置</a>'.($subnav ? ' &raquo; '.$subnav : '');
include template("config", _ROOT . "/template/admin/");
?>